package com.itheima.app.exception;

import com.itheima.vo.dbvo.ErrorResult;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.ExceptionHandler;

@Component
public class GlobalExceptionAdvice {

    @ExceptionHandler(Exception.class)
    public ResponseEntity handlerExceptionMethod(Exception ex){
        //将异常信息输入到控制台
        ex.printStackTrace();
        //给前端友好提示
        return ResponseEntity.status(500).body(ErrorResult.error());
    }
}
